import axios, { AxiosInstance, AxiosRequestConfig } from "axios";

const { VITE_BASE_URL, VITE_USE_MOCK } = import.meta.env;

type AxiosRequestConfigOmit = Omit<AxiosRequestConfig, "params" | "url" | "method">;

class Axios {
  private instance: AxiosInstance;

  constructor() {
    this.instance = axios.create({
      baseURL: VITE_USE_MOCK ? undefined : VITE_BASE_URL,
      timeout: 10000,
    });
  }

  public getInstance(): AxiosInstance {
    return this.instance;
  }

  // public get<T = unknown>(url: string, params: any, config?: AxiosRequestConfigOmit) {
  //   return this.instance.request<T>({
  //     ...config,
  //     url,
  //     params,
  //     method: "get",
  //   });
  // }

  // public post<T = unknown>(url: string, params: any, config?: AxiosRequestConfigOmit) {
  //   return this.instance.request<T>({
  //     ...config,
  //     url,
  //     params,
  //     method: "post",
  //   });
  // }

  // public put<T = unknown>(url: string, params: any, config?: AxiosRequestConfigOmit) {
  //   return this.instance.request<T>({
  //     ...config,
  //     url,
  //     params,
  //     method: "put",
  //   });
  // }

  // public delete<T = unknown>(url: string, params: any, config?: AxiosRequestConfigOmit) {
  //   return this.instance.request<T>({
  //     ...config,
  //     url,
  //     params,
  //     method: "delete",
  //   });
  // }
}

const request = new Axios().getInstance();
export default request;
